﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;

public partial class fileupload : System.Web.UI.Page
{
    String thumuc;
    protected void Page_Load(object sender, EventArgs e)
    {
        thumuc = "G:\\Uploadfile";
        bool tontai = Directory.Exists(thumuc);
        if (tontai == false)
        {
            Directory.CreateDirectory(thumuc);
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Label1.Text = FileUpload1.PostedFile.FileName;
        Label2.Text = FileUpload1.PostedFile.ContentType;
        Label3.Text = FileUpload1.PostedFile.ContentLength + "KB";
        Label4.Visible = true;
        String tenfile = Path.GetFileName(FileUpload1.PostedFile.FileName);
        try
        {
            FileUpload1.SaveAs(thumuc + "\\" + tenfile);

        }
        catch
        {
            Label4.Text = "Upload that bai";
        }
    }
}
